import re

'''
参考1: https://blog.csdn.net/qq_34355232/article/details/84189901
参考2: https://www.cnblogs.com/cp-miao/p/5567115.html
'''

# '\d{3}' 为十进制的数字连续出现3次
str1 = "123aaa"
print(re.search('\d{3}', str1))
# <re.Match object; span=(0, 3), match='123'>

# [] 为匹配中括号里面的任意一个字符
str2 = 'Delhui_2012'
print(re.search('[abcABCD]', str2))
# <re.Match object; span=(0, 1), match='D'>
